New semantics for `--features` flag
authorAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 13 Apr 2018 14:36:09 +0000 (17:36 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Fri, 13 Apr 2018 14:36:09 +0000 (17:36 +0300)
commit8d0b31b975e8dd168f71fa9a5d61100ac0b3ac74
tree696cd54fc6b433c81721822a2db798a8a59ef6a8
parent8afcf45dcd16fc560329eba7950c39b917856395
New semantics for `--features` flag

Historically, feature-related flags like `--all-features`,
`--no-default-features` and `--features` operated on the *current*
package. That is, `cargo --package foo --feature feat` would activate
`feat` for the package at the current working directory, and not for the
`foo` package. `-Z package-features` flag implements the more obvious
semantics for this combination of flags. This changes behavior, and that
is why we want to start with an unstable opt-in. The changes are:

* `--feature` flag affects the selected package. It is an error to
  specify `--feature` with more than a single `-p`, or with `-p` outside
  workspace (the latter could work in theory, but would be hard to
  implement).

* `--all-features` and `--no-default-features` affect all selected
  packages, and not the one at cwd.

* The package in `cwd` is not implicitly enabled when doing feature
  selection. That is, `cargo build -Z package-features -p foo` could
  select *less* features for various packages than `cargo build -p foo`.
src/cargo/core/features.rs
src/cargo/ops/resolve.rs
tests/testsuite/features.rs